<?php
namespace Admin\Controller;
use Think\Controller;
class LoginController extends Controller {	
	public function index(){
        $this->assign('title', 'ICP_ADMIN_LOGIN');
        $this->display();
    }
	
	public function logout() {
		session(null); // 清空当前的session
		$data['status'] = 1;
		$data['content'] = 'ok';
		$this->ajaxReturn($data);
	}
	
	public function login() {
		$name = I('post.lname');
		$pass = I('post.lpass');
		$condition = 'lname="'.$name.'" AND pass="'.$pass.'"';
		$ICPUser = M('muser');
		$result = $ICPUser->where($condition)->find();
		if ($result == false) {
			$data['status'] = 0;
			$data['content'] = '登陆失败';
		} else {
			if ($result == NULL) {
				$data['status'] = 0;
				$data['content'] = '登录失败,用户不存在或用户名/密码错误';
			} else {
				$data['status'] = 1;
				$data['content'] = 'ok';
				session('name', $name);
			}
		}
		$this->ajaxReturn($data);
	}
}
?>